import os
from huggingface_hub import snapshot_download

def download_model():
    """
    从国内镜像下载BAAI/bge-large-zh-v1.5模型
    """
    # 设置环境变量使用国内镜像
    os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
    
    print("正在从国内镜像下载 BAAI/bge-large-zh-v1.5 模型...")
    print("这可能需要一些时间，请耐心等待...")
    
    try:
        # 下载模型到本地目录
        model_path = snapshot_download(
            repo_id="BAAI/bge-large-zh-v1.5",
            local_dir="./models/bge-large-zh",
            resume_download=True  # 支持断点续传
        )
        print(f"模型已成功下载到: {model_path}")
        return model_path
    except Exception as e:
        print(f"下载过程中出现错误: {e}")
        print("请检查网络连接或稍后重试")
        return None

if __name__ == "__main__":
    download_model()